package com.aliyun.configuration;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.common.constant.Constant;
/*
 * 配置管理组件
 */
public class ConfigurationTool {
	
	private static Properties properties = new Properties();
	
	static{
		InputStream in = ConfigurationTool.class.getClassLoader().getResourceAsStream("my.properties");
		try {
			properties.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	/*
	 * 返回类型是  字符串型
	 */
	public static String getProperties(String key) {
		return properties.getProperty(key);
	}
	
	public static void main(String[] args) {
		 StringBuffer composeYaml = new StringBuffer();
		 for(int i = 1; i <= 2; i++ ){
			 
			 composeYaml.append(ConfigurationTool.getProperties(Constant.ZK_CONTAINER_NAME)+ i + ConfigurationTool.getProperties(Constant.ZK_CONTAINER_NAME_SUFFIX))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_IMAGE))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_HOSTNAME)+ i + ConfigurationTool.getProperties(Constant.NEWLIN_SYSBOL))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_VOLUMES) 
								+ "    " + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_PATH) + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_NAME) + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCALNAME_CONF)
								+ "    " + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_PATH) + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_NAME) + i + ConfigurationTool.getProperties(Constant.ZK_VOLUMES_SUFFIX_DATA)
								+ "    " + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_PATH) + ConfigurationTool.getProperties(Constant.ZK_VOLUMESLOCAL_NAME) + i + ConfigurationTool.getProperties(Constant.ZK_VOLUMES_SUFFIX_LOGS))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_RESTART))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_PORTS))
				.append("  " + ConfigurationTool.getProperties(Constant.ZK_ENVIRONMENT_A) + i + ConfigurationTool.getProperties(Constant.NEWLIN_SYSBOL)) 
				.append(ConfigurationTool.getProperties(Constant.ZK_OTHERARGS))
				;
		 }
		 System.out.println(composeYaml);
		 
//		System.out.println(ConfigurationTool.getProperties("newLinSysbol")+"master-hadoop"+ConfigurationTool.getProperties("volumesToConYaml"));
	}
	
	
}
